package net.yambal.android.air.roulette
{
	import flash.media.Video;
	
	import mx.core.UIComponent;
	import mx.events.FlexEvent;
	
	import spark.components.Label;
	import spark.components.TextArea;
	
	public class RoulettePeace extends UIComponent
	{
		private var _roulrtte_peace:FanSprite;
		private var _label:Label;
		private var _isCreated:Boolean = false;
		
		//private var _text:String = null;
		private var _routrelle_item:RouletteItem = null;
		
		private var _degree:Number = -1;
		
		public function RoulettePeace()
		{
			super();
			
			addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
			
		}
		
		private function onCreationComplete(e:FlexEvent):void{
			trace(this + "onCreationComplete");
			_isCreated = true;
			
			_roulrtte_peace = new FanSprite();
			
			_label = new Label();
			_label.setStyle("color", "#FFFFFF");
			_label.setStyle("fontSize", "12");
			_label.setStyle("textAlign", "center");
			_label.setStyle("lineBreak", "toFit");
			_label.maxDisplayedLines = -1;
			_label.width = 80;
			_label.height = 12;
			_label.x = 10;
			_label.y = -6;
			
			
			addChildAt(_label,0);
			addChildAt(_roulrtte_peace,0);
			
			
			// draw
			if(_routrelle_item != null){
				roulette_item = _routrelle_item;
			}
			
			if(_degree > 0){
				degree = _degree;
			}
		}
		
		public function set roulette_item(item:RouletteItem):void{
			_routrelle_item = item;
			if(_isCreated){
				_label.text = _routrelle_item.label;
				setLabelRotation();
			}
		}
		
		/*
		public function set text(text:String):void{
			_text = text;
			if(_isCreated){
				_label.text = text;
				setLabelRotation();
			}
		}
		*/
		
		public function set degree(degree:Number):void{
			_degree = degree;
			if(_isCreated){
				_roulrtte_peace.degree = degree;
			}
		}
		
		public function setRotation(_rotation:Number):void{
			rotation = _rotation - 90;
			
			setLabelRotation();
		}
		
		private function setLabelRotation():void{
			if(_label){
				if(rotation + 90 > 0 && rotation + 90 < 181){
					
				}else{
					_label.rotation = 180;
					_label.x = 90;
					_label.y = 6;
				}
			}	
		}
		
		//
		public function set grow(flg:Boolean):void{
			if(_roulrtte_peace != null){
				if(flg){
					_roulrtte_peace.alpha = 1;
				}else{
					_roulrtte_peace.alpha = .75;
				}
			}
		}
	}
}